#include<iostream>
#include<cstdio>
using namespace std;
const int N = 5e6 + 10;
int arr[N];
int n, k;
int quick_sort(int l, int r)
{
	if (l >= r) {
		return arr[l];
	}
	int x = arr[l + r >> 1];
	int i = l - 1;
	int j = r + 1;
	while (i < j) {
		do i++;
		while (arr[i] < x);
		do j--;
		while (arr[j] > x);
		if (i < j) {
			int temp = arr[i];
			arr[i] = arr[j];
			arr[j] = temp;
		}
	}
	if (k <= j) {
		return quick_sort(l, j);
	}
	else {
		return quick_sort(j + 1, r);
	}
}
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	int ret = quick_sort(0, n - 1);
	printf("%d", ret);
	return 0;
}